home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.09 Sep 90 / CursorControl Folder / Control.c next >
Encoding:
Text File  |  1989-08-26  |  820 b   |  38 lines  |  [TEXT/KAHL]

  1. /*******
  2.  * HandleMouse()
  3.  *
  4.  * Checks the cursor position and calls MousePos if necessary
  5.  *
  6.  *******/
  7.  
  8. HandleMouse(boundsRect)
  9. Rect    *boundsRect;
  10. {
  11. Point        mousePoint;
  12. Point        newPoint;
  13.  
  14.     GetMouse(&mousePoint);
  15.     LocalToGlobal(&mousePoint);
  16.     
  17.     newPoint.h = newPoint.v = -1;
  18.     
  19.     if (mousePoint.h <= boundsRect->left)
  20.             newPoint.h = boundsRect->right - 2;
  21.     else
  22.         if (mousePoint.h >= boundsRect->right - 1)
  23.             newPoint.h = boundsRect->left + 1;
  24.     if (mousePoint.v <= boundsRect->top)
  25.             newPoint.v = boundsRect->bottom - 2;
  26.     else
  27.         if (mousePoint.v >= boundsRect->bottom - 1)
  28.             newPoint.v = boundsRect->top + 1;
  29.     
  30.     if ( (newPoint.h + 1) || (newPoint.v + 1) )
  31.         {
  32.             newPoint.h = (newPoint.h != -1) ? newPoint.h : mousePoint.h;
  33.             newPoint.v = (newPoint.v != -1) ? newPoint.v : mousePoint.v;
  34.             
  35.             MousePos(newPoint);
  36.         }
  37. }
  38.